package com.training.collections.vo;

import java.io.Serializable;
import java.util.Date;

public class Employee implements Serializable, Comparable {

	private String name;
	private String id;
	private Date joiningDate;

	/**
	 * @return the joiningDate
	 */
	public Date getJoiningDate() {
		return joiningDate;
	}

	/**
	 * @param joiningDate
	 *            the joiningDate to set
	 */
	public void setJoiningDate(Date joiningDate) {
		this.joiningDate = joiningDate;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}

	public Employee(String name, String id) {

		this.name = name;
		this.id = id;

	}

	public void display() {
		System.out.println(" Employee Name is -- " + this.name + "   Id is -- "
				+ this.id);
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the id
	 */
	public String getId() {
		return id;
	}

	@Override
	public boolean equals(Object obj) {

		if (obj instanceof Employee) {
			Employee employee = (Employee) obj;

			if (employee.getName().equalsIgnoreCase(this.name)
					&& employee.getId().equalsIgnoreCase(this.id)) {
				return true;
			}

		}

		return false;
	}

	@Override
	public int hashCode() {
		return this.name.hashCode() + id.hashCode();
	}

	@Override
	public int compareTo(Object arg0) {
		if (arg0 instanceof Employee) {
			Employee employee = (Employee) arg0;
			return this.getName().compareTo(employee.getName());

		}
		return 0;
	}

}